#include "../AbstractFactory/mazefactory.h"
#include "mazebuilder.h"
#include "maze.h"
#include "wall.h"
#include "room.h"
#include "door.h"
#include "mazegame.h"

Maze *MazeGame::createMaze()
{
    Maze *aMaze = new Maze;

    Room *r1 = new Room(1);
    Room *r2 = new Room(2);
    Door *theDoor = new Door(r1, r2);

    aMaze->addRoom(r1);
    aMaze->addRoom(r2);

    r1->setSide(D_North, new Wall);
    r1->setSide(D_South, theDoor);
    r1->setSide(D_East, new Wall);
    r1->setSide(D_West, new Wall);

    r2->setSide(D_North, new Wall);
    r2->setSide(D_South, new Wall);
    r2->setSide(D_East, new Wall);
    r2->setSide(D_West, theDoor);

    return aMaze;
}

Maze *MazeGame::createMaze(MazeFactory &factory)
{
    Maze *aMaze = factory.makeMaze();

    Room *r1 = factory.makeRoom(1);
    Room *r2 = factory.makeRoom(2);
    Door *theDoor = factory.makeDoor(r1, r2);

    aMaze->addRoom(r1);
    aMaze->addRoom(r2);

    r1->setSide(D_North, factory.makeWall());
    r1->setSide(D_South, theDoor);
    r1->setSide(D_East, factory.makeWall());
    r1->setSide(D_West, factory.makeWall());

    r2->setSide(D_North, factory.makeWall());
    r2->setSide(D_South, factory.makeWall());
    r2->setSide(D_East, factory.makeWall());
    r2->setSide(D_West, theDoor);

    return aMaze;
}

Maze *MazeGame::createMaze(MazeBuilder &builder)
{
    builder.buildMaze();
    builder.buildRoom(1);
    builder.buildRoom(2);
    builder.buildDoor(1, 2);

    return builder.maze();
}
